// pages/salesman/main/index.js
var app = getApp()
var lastClickTime = 0
var minClickTime = app.globalData.minClickTime
var encryptUtils = require('../../../utils/HHEncryptUtils.js')
var modelUtils = require('../../../utils/HHModelUtils.js')
var baseImgPath = app.globalData.imgBasepath
var pageSize = app.globalData.pageSize
var default_img = baseImgPath + app.globalData.default_img
var pageIndex = 1
var loading = false;
Page({
    /**
     * 页面的初始数据
     */
    data: {
        table: [
            { img: "../../../images/main_top1.png", imgSelect: "../../../images/main_top1_select.png", text: "客户管理", select: true },
            { img: "../../../images/main_top2.png", imgSelect: "../../../images/main_top2_select.png", text: "预期处理", select: false },
            { img: "../../../images/main_top3.png", imgSelect: "../../../images/main_top3_select.png", text: "收入管理", select: false }
        ],
        loading: false,
        complate: true,
        noData: false,
        loadMore: false,
        // loading: true,
        // complate: false,
        // noData: false,
        // loadMore: false,
        noDataMsg: "暂无数据",
        // loaingImg: baseImgPath + app.globalData.loading,
        loaingImg: "http://qq.yh31.com/tp/zjbq/201710092308481521.gif",
        noDataImg: baseImgPath + app.globalData.no_data,
        yuqi: baseImgPath + app.globalData.yuqi,
        addUser: "../../../images/add_user.png",
        addJie: "../../../images/add_jie.png",
        tongji: "../../../images/tongji.png",
        tixian: "../../../images/tixian.png",
        notice: "../../../images/msg.png",
        userList:[1,1,1,1,1,1,1,1,1,1],
        yiqiList:[1,1,1,1,1,1,1,1,1,1],
        earnList:[1,1,1,1,1,1,1,1,1,1],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    tableClick: function (event) {

        var index = event.currentTarget.id;
        console.log("index==" + index);
        var table = this.data.table
        if (table[index].select) {
            return
        }
        for (var i = 0; i < table.length; i++) {
            table[i].select = false
        }
        table[index].select = true
        wx.setNavigationBarTitle({
            title: table[index].text,
        })
        this.setData(
            {
                table: table
            }
        )
        // wx.navigateTo({
        //     url: '../../notice/list',
        // })
    },
    onclickLitener: function (event) {
        var clickTime = Date.now()

        if (clickTime - lastClickTime <= minClickTime) {

            return
        }
        lastClickTime = clickTime

        var clickid = event.currentTarget.id
        var table = this.data.table
        switch (clickid) {
            case "1":
                if (table[0].select)//新增用户
                {
                    wx.navigateTo({
                        url: '../addUser/add',
                    })

                } else//业务统计
                {
                    wx.navigateTo({
                        url: '../statistics/list',
                    })
                }

                break
            case "2"://业务统计
                if (table[0].select)//新增借款
                {
                    wx.navigateTo({
                        url: '../addloan/add',
                    })

                } else//余额提现
                {

                }

                break
            case "3":// 今日收入
                wx.navigateTo({
                    url: '../../calendar/index',
                })
                break
            case "4"://余额提现
                break
        }
    },
    toNotice: function () {
        var clickTime = Date.now()

        if (clickTime - lastClickTime <= minClickTime) {

            return
        }
        lastClickTime = clickTime
        wx.navigateTo({
            url: '../../notice/list',
        })
    }
})